//
//  ViewController.swift
//  actors1
//
//  Created by 李煜 on 2024/8/15.
//

import UIKit

class ViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()
    
    Task {
      await testActor()
    }
  }

  func testActor() async {
    let logger = TemperatureLogger(label: "Outdoors", measurement: 25)
    print(await logger.max)
  }

}

actor TemperatureLogger {
  let label: String
  var measurements: [Int]
  private(set) var max: Int
  
  init(label: String, measurement: Int) {
    self.label = label
    self.measurements = [measurement]
    self.max = measurement
  }
}
